﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Imaginecup.gameState;
using Microsoft.Xna.Framework.Input;
using Imaginecup.Recycling.Behavior;
using Imaginecup.Recycling.GameMan;
using Imaginecup.recycling.Object.Entity;
using Imaginecup.shareData;
using Imaginecup.util.Funtion;

namespace Imaginecup.Recycling.Object
{
    public class MoveObject : GameObject
    {
        private IMovingBehavior Run;
        public MoveObject(string textureName)
        {
            InitMember(textureName);
        }
        
        public MoveObject(string textureName, int speed)
        {
            InitMember(textureName);
            Run.SetSpeed(speed);
        }
        public MoveObject(string textureName, bool flag)
        {
            InitMember(textureName);
            Run.SetLoopFlag(flag);
        }

        private void InitMember(string textureName)
        {
            m_TextureName = textureName;

            m_Info = new ObjectInfo(
                new Rectangle(-200, UserRandom.rand.Next(100) + 10, 96, 96)
            );
            Run = new Run(m_Info);
        }

        public void SetMovingBehavior(IMovingBehavior mb)
        {
            Run = mb;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            Run.UpdateMove(gameTime);
        }
    }
}
